home *** CD-ROM | disk | FTP | other *** search
- Some of the useful extra built-in or external predicates
- in Open Prolog 1.0d26 are listed below:
-
-
- 'system$menu'(set,MenuName,MenuItemName,Enable,Icon,KeyEquivalent).
- %always use 'set' for the first argument
- %Enter 'enabled' or 'disabled' or '' in the Enable field.
- %Enter Icon Number or 0 in Icon Field
- %Enter Keyboard Equivalent in KeyEquivalent Field (only works for a new menu).
- 'system$menu' can be used to enable & disable existing menu items.
- The system adds 256 to the icon number you provide, if it's not 0.
- (Supply your own icons using something like ResEdit.)
- example:
- 'system$menu'(set,'Trixi','Help',enabled,1,'Y').
- When the menu is selected by the user, Open Prolog looks for a clause
- with a head of the form:
- 'system$menu$hook'(MenuName,MenuItemName)
- If it is found, the clause is executed.
-
- 'system$alert'(alertMessage1,alertMessage2,alertMessage3,alertMessage4).
- %must not be structured terms. They are concatenated & displayed.
- 'system$confirm'(message1,message2,message3,message4).
- %must not be structured terms. They are concatenated & displayed.
- Succeeds or fails depending on Yes or No button.
- 'system$predicate'(Name,Term,Kind).
- 'system$owner$name'(Name). %used to be 'system$username'(X).
- 'system$machine$name'(Name). %System 7.
- 'system$seconds'(Seconds). %Since 1/1/1904 - negative but don't worry.
- 'system$date'(Seconds,Date). %Seconds is always input
- 'system$time'(Seconds,Time). %Seconds is always input
- 'system$random'(Range,RandomNumber). %range is always input
- %range is 1 to Range, or -1 to Range. Don't ask for Range of -1, 0 or +1.
-
- say(Phrase,Volume) needs MacinTalk to work.
- Due to a bug in Macintalk, all other sounds are disabled!
- The Phrase must be an atom or a number.
- Pass a Volume of 0 - 7. A volume of 0 means the current setting
- will be used.
-
- eg.
- 'system$username'(X),say('Hi',7),say(X,7).
-
- macsbug & macsbugFail need Macsbug to work, and will crash otherwise.
-
- play(SoundName,Volume) will play any Type 1 'snd ' resource.
- Sounds recorded with the new ╘Sound╒ Control Panel Device and
- all the sounds for the System Bell are snds of this type.
- To play them, give their names exactly as they appear in
- the ╘Sound╒ Control Panel Device.
- Be careful to get spacing and punctuation exactly right.
- If the sound can't be found, or is too big to fit into memory,
- the call will fail,
- Pass a Volume of 0 - 7. A volume of 0 means the current setting
- will be used.
-
- E.g.
- play('Simple Beep',5).
-
- The snd resources can be resident in any open window, the Worksheet,
- Open Prolog itself, or the System.
-
- 'open$prolog$eof$char'(CurrentEofChar,NewEofChar). %default is 26
- 'open$prolog$eoln$char'(CurrentEolnChar,NewEolnChar). %default 31
-
- 'system$show$about' %Shows the About Open Prolog╔ box
-
- 'toolbox$GetIndString'(Atom,ResourceNumber,Index). %same as the Mac
- Toolbox GetIndString, where the string is turned into an atom.
-
- Window-handling Predicates.
-
- A number of predicates have been written to handle window-based I/O.
- Please be aware that they are subject to change.
-
- Basic Ideas:
- ╫ Window Numbers
- We use window numbers because
- it is not possible to refer to a window by its name. This is because its
- name may change, and because (in theory anyway) many windows can
- have the same names.
- So, every window is assigned a window number when it
- is created (distinct from its parameter pointer or file number etc.).
-
- ╫ Starting Pointer & Single-Line-Selection
- Whenever text is output
- to a window (say using the write command), a pointer, called the
- starting pointer, is made point to the next character after the last
- character output.
-
- When a user selects text using the Enter key, the text selected goes
- into a text buffer that is passed to the Prolog interpreter.
- In the case of single-line-selection, the
- start of the selection is computed by going from the caret backwards
- along the line to the start of the line or to the starting pointer,
- whichever comes first. The end of the selection is the end of the line.
-
- ╫ Highlighting & Outlines
- It is possible to highlight a particular run of text. Just to confuse you,
- the highlight is called an outline, because that's how it started out.
- The highlight will 'stick' to the text specified even when text before,
- within or after it has been added or removed. Therefore it's not safe to
- refer to a highlight by its start & end points, which may vary. Instead, a
- highlight is given a unique index number by which it may be referred to
- later.
-
- ╫ Some Built-Ins
-
- 'system$window$open$file$window'(Name,WindowNumber,ResultCode)
- A window is opened with the name given (or brought to the front if it's
- open already). If a file of the same name exists, then it's opened into the
- window if possible. A result code of 0 indicates everything was OK;
- anything else means some error occured. It's not an error to not find a
- corresponding file.
-
- 'system$window$set$starting$point'(WindowNumber,StartingPoint) &
- 'system$window$get$starting$point'(WindowNumber,StartingPoint)
- These can be used to get and set the starting point. Normally you needn't
- bother with these, as the starting point is automatically updated.
- Sometimes, however, you 'll need them. For example, say you've written
- a parser, and you want to indicate errors to the user in the window.
- When you display the error message as appropriate, you'll want to
- reset the window environment more or less exactly as is was just before
- the error occured. For this, you'll need to get the starting point beforehand,
- and then reset it after outputting the error message, etc.
- I have a rather complex example, so mail me if you'd like it.
-
- 'system$window$front'(WindowNumber)
- Tells you which window is at the front.
-
- 'system$window$get$output'(WindowNumber).
- Tells you which is the current output window.
-
- 'system$window$set$output'(WindowNumber,Status).
- The designated window becomes the output window. Any error (e.g. if
- the window is read-only, etc. will be reported in Status. A Status of 0
- means OK.
-
- 'system$window$select'(WindowNumber).
- Bring the window to the front.
-
- 'system$window$get$selection'(WindowNumber,Start,End)
- Tells you the selection start and end.
-
- 'system$window$set$selection'(WindowNumber,Start,End)
- Allows you to set the selection start and end.
-
- 'system$window$set$outline'(WindowNumber,StyleNumber,
- Start,End,OutlineReference).
- Only a style 1 is defined.
-
- 'system$window$clear$outline'(WindowNumber,OutlineReference)